﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <div>
    <el-form ref="formRefSpcAnalysis" :model="stateSpcAnalysis.vmModel" label-width="100px">
      <el-row>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Code_FormItem" prop="Entity.Code" :label="$t('message.autotrans._Model_SpcAnalysis_Code')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_SpcAnalysis_Code')}), trigger: 'blur' }]" >
            <el-input v-model="stateSpcAnalysis.vmModel.Entity.Code" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Desc_FormItem" prop="Entity.Desc" :label="$t('message.autotrans._Model_SpcAnalysis_Desc')">
            <el-input v-model="stateSpcAnalysis.vmModel.Entity.Desc" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_ChartType_FormItem" prop="Entity.ChartType" :label="$t('message.autotrans._Model_SpcAnalysis_ChartType')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_SpcAnalysis_ChartType')}), trigger: 'blur' }]" >
            <el-select v-model="stateSpcAnalysis.vmModel.Entity.ChartType" disabled clearable>
               <el-option key="C" value="C" :label="$t('message.autotrans._Enum_SpcChartTypeEnum_C')"></el-option>
               <el-option key="C_U" value="C_U" :label="$t('message.autotrans._Enum_SpcChartTypeEnum_C_U')"></el-option>
               <el-option key="NP_P" value="NP_P" :label="$t('message.autotrans._Enum_SpcChartTypeEnum_NP_P')"></el-option>
               <el-option key="Xbar_R_Xbar_S" value="Xbar_R_Xbar_S" :label="$t('message.autotrans._Enum_SpcChartTypeEnum_Xbar_R_Xbar_S')"></el-option>
               <el-option key="U" value="U" :label="$t('message.autotrans._Enum_SpcChartTypeEnum_U')"></el-option>
               <el-option key="NP" value="NP" :label="$t('message.autotrans._Enum_SpcChartTypeEnum_NP')"></el-option>
               <el-option key="P" value="P" :label="$t('message.autotrans._Enum_SpcChartTypeEnum_P')"></el-option>
               <el-option key="I_MR" value="I_MR" :label="$t('message.autotrans._Enum_SpcChartTypeEnum_I_MR')"></el-option>
               <el-option key="Xbar_S" value="Xbar_S" :label="$t('message.autotrans._Enum_SpcChartTypeEnum_Xbar_S')"></el-option>
               <el-option key="Xbar_R" value="Xbar_R" :label="$t('message.autotrans._Enum_SpcChartTypeEnum_Xbar_R')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_ProductId_FormItem" prop="Entity.ProductId" :label="$t('message.autotrans._Model_SpcAnalysis_ProductId')">
            <el-input v-model="stateSpcAnalysis.vmModel.Entity.ProductId" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_ProductName_FormItem" prop="Entity.ProductName" :label="$t('message.autotrans._Model_SpcAnalysis_ProductName')">
            <el-input v-model="stateSpcAnalysis.vmModel.Entity.ProductName" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_OpId_FormItem" prop="Entity.OpId" :label="$t('message.autotrans._Model_SpcAnalysis_OpId')">
            <el-input v-model="stateSpcAnalysis.vmModel.Entity.OpId" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_OpName_FormItem" prop="Entity.OpName" :label="$t('message.autotrans._Model_SpcAnalysis_OpName')">
            <el-input v-model="stateSpcAnalysis.vmModel.Entity.OpName" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_ChartName_FormItem" prop="Entity.ChartName" :label="$t('message.autotrans._Model_SpcAnalysis_ChartName')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_SpcAnalysis_ChartName')}), trigger: 'blur' }]" >
            <el-input v-model="stateSpcAnalysis.vmModel.Entity.ChartName" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_DataName_FormItem" prop="Entity.DataName" :label="$t('message.autotrans._Model_SpcAnalysis_DataName')">
            <el-input v-model="stateSpcAnalysis.vmModel.Entity.DataName" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_DataTag_FormItem" prop="Entity.DataTag" :label="$t('message.autotrans._Model_SpcAnalysis_DataTag')">
            <el-input v-model="stateSpcAnalysis.vmModel.Entity.DataTag" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_SimpleQty_FormItem" prop="Entity.SimpleQty" :label="$t('message.autotrans._Model_SpcAnalysis_SimpleQty')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_SpcAnalysis_SimpleQty')}), trigger: 'blur' }]" >
            <el-input v-model="stateSpcAnalysis.vmModel.Entity.SimpleQty" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_UCL_FormItem" prop="Entity.UCL" :label="$t('message.autotrans._Model_SpcAnalysis_UCL')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_SpcAnalysis_UCL')}), trigger: 'blur' }]" >
            <el-input v-model="stateSpcAnalysis.vmModel.Entity.UCL" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_CL_FormItem" prop="Entity.CL" :label="$t('message.autotrans._Model_SpcAnalysis_CL')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_SpcAnalysis_CL')}), trigger: 'blur' }]" >
            <el-input v-model="stateSpcAnalysis.vmModel.Entity.CL" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_LCL_FormItem" prop="Entity.LCL" :label="$t('message.autotrans._Model_SpcAnalysis_LCL')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_SpcAnalysis_LCL')}), trigger: 'blur' }]" >
            <el-input v-model="stateSpcAnalysis.vmModel.Entity.LCL" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_USL_FormItem" prop="Entity.USL" :label="$t('message.autotrans._Model_SpcAnalysis_USL')">
            <el-input v-model="stateSpcAnalysis.vmModel.Entity.USL" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_LSL_FormItem" prop="Entity.LSL" :label="$t('message.autotrans._Model_SpcAnalysis_LSL')">
            <el-input v-model="stateSpcAnalysis.vmModel.Entity.LSL" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_SubgroupSize_FormItem" prop="Entity.SubgroupSize" :label="$t('message.autotrans._Model_SpcAnalysis_SubgroupSize')">
            <el-input v-model="stateSpcAnalysis.vmModel.Entity.SubgroupSize" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_CreateTime_FormItem" prop="Entity.CreateTime" :label="$t('message.autotrans._Model_SpcAnalysis_CreateTime')">
            <el-input v-model="stateSpcAnalysis.vmModel.Entity.CreateTime" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_UpdateTime_FormItem" prop="Entity.UpdateTime" :label="$t('message.autotrans._Model_SpcAnalysis_UpdateTime')">
            <el-input v-model="stateSpcAnalysis.vmModel.Entity.UpdateTime" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_CreateBy_FormItem" prop="Entity.CreateBy" :label="$t('message.autotrans._Model_SpcAnalysis_CreateBy')">
            <el-input v-model="stateSpcAnalysis.vmModel.Entity.CreateBy" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_UpdateBy_FormItem" prop="Entity.UpdateBy" :label="$t('message.autotrans._Model_SpcAnalysis_UpdateBy')">
            <el-input v-model="stateSpcAnalysis.vmModel.Entity.UpdateBy" disabled clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

      <WtmTable ref="tableRefSimpleDataSheetList2" v-bind="tableDataSimpleDataSheetList2" v-model="stateSpcAnalysis.vmModel.Entity.SimpleData_Sheet" disabled></WtmTable>
      <div style="text-align:right;">
        <WtmButton @click="onCloseSpcAnalysis"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

      </div>

    </el-form>

  </div>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageSpcManagementSpcAnalysisDetails;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { spcanalysisApi } from '/@/api/spcmanagement/spcanalysis';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const tableRefSimpleDataSheetList2 = ref();
const tableDataSimpleDataSheetList2 = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
      {title:ci.proxy.$t('message.autotrans.Page批次号'),key: 'BatchId',type: 'textbox',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page追溯码'),key: 'Sn',type: 'textbox',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page测量值'),key: 'SimpleValue',type: 'textbox',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page采样时间'),key: 'SimpleTime',type: 'date',isCheck: true},

	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: false, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
        isSub:true,
        isDisabled:true
	}
});

// 定义变量内容
const formRefSpcAnalysis = ref();
const stateSpcAnalysis = reactive({
    vmModel: {
	  Entity:{
        Code: '',
        Desc: '',
        ChartType: undefined,
        ProductId: null,
        ProductName: '',
        OpId: null,
        OpName: '',
        ChartName: '',
        DataName: '',
        DataTag: '',
        SimpleQty: null,
        UCL: null,
        CL: null,
        LCL: null,
        USL: null,
        LSL: null,
        SubgroupSize: null,
        CreateTime: undefined,
        UpdateTime: undefined,
        CreateBy: '',
        UpdateBy: '',
        SimpleData_Sheet:[],
        ID:null,
      },

	},
    
    AllSheets: [] as any[],
});

// 取消
const onCloseSpcAnalysis = () => {
    closeDialog();
};

// 提交
const onSubmitSpcAnalysis = () => {
 	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});
   formRefSpcAnalysis.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            spcanalysisApi().edit(stateSpcAnalysis.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
        else{
			loadingInstance.close();
        }
	})
};

// 页面加载时
onMounted(() => {
    
    other.getSelectList('/api/SpcManagement/SimpleData/GetSpcAnalysiss',[],false).then(x=>{stateSpcAnalysis.AllSheets = x});
    if (ci.attrs["wtmdata"]) {
		stateSpcAnalysis.vmModel.Entity.ID = ci.attrs["wtmdata"].ID;
	}
	else if (useRouter().currentRoute.value.query.id) {
		stateSpcAnalysis.vmModel.Entity.ID = useRouter().currentRoute.value.query.id as any;
	}
	spcanalysisApi().get(stateSpcAnalysis.vmModel.Entity.ID ?? "").then((data: any) => other.setValue(stateSpcAnalysis.vmModel, data));
});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

